package com.source.multithread.threadd;

/**
 * @Author wengqy
 * @Date 2020/12/25
 */
public class ThreadDemo3 {
    public static void main(String[] args) throws InterruptedException {
        MM mm = new MM();
        new Thread(mm,"test sub").start();
        Thread.sleep(5000);
        System.out.println("main start...");


        Thread.sleep(100);
        System.out.println(" main--  name:  "+Thread.currentThread().getName()+"   hashcode:  "+Thread.currentThread().hashCode()+"  Thread: "+Thread.currentThread());
        System.out.println(Thread.currentThread().getName()+"----------"+Thread.activeCount());
        Thread.sleep(5000);
        System.out.println(Thread.currentThread().getName()+"----------"+Thread.activeCount());
        System.out.println("main end...");
    }
}

class MM implements  Runnable{

    @Override
    public void run() {
        System.out.println("sub start...");
        try {
            System.out.println(Thread.currentThread().getName());
            Thread.sleep(100);

        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("sub--  name:  "+Thread.currentThread().getName()+"   hashcode:  "+Thread.currentThread().hashCode()+"  Thread: "+Thread.currentThread());
        System.out.println("sub end...");
    }
}